#pragma once

	//safe delete
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) if (p) {delete (p); (p) = 0;}
#endif //

//bzeor (in windows there's no such system function so..)
#ifdef _iMate_Win
void bzero(void* data, size_t size);
#endif 

//just a short-cut way of counting elements in an array
#ifndef count_of
#define count_of(array) (sizeof((array)[0]) == 0 ? 0 : sizeof(array) / sizeof((array)[0]))
#endif

//bit set tool
#ifndef BIT
#define BIT(i) (1 << (i))
#endif

namespace iMate {

	inline bool isBitSet(const unsigned char* bits, const int bitPos)
	{
		return 0 != (bits[bitPos / 8] & (0xff & (1 << (bitPos % 8))));
	}

	inline void setBit(unsigned char* bits, const int bitPos)
	{
		bits[bitPos / 8] |= (0xff & (1 << (bitPos % 8)));
	}


}//iMate